package com.yaodian.controller;



import com.yaodian.service.impl.StaffServiceImpl;
import com.yaodian.vo.StaffVo;
import com.yaodian.vo.UpdateStaffVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


/**
 * (Staff)表控制层
 *
 * @author makejava
 * @since 2025-01-19 11:07:41
 */
@RestController
@Api(value = "用户数据测试",tags = "用户数据接口API")
@RequestMapping("/staff")
public class StaffController {
    /**
     * 服务对象
     */
    @Resource
    private StaffServiceImpl staffService;

    /**
     * 查询员工数据
     *
     */
    @GetMapping("/selectStaff")
    @ApiOperation(value = "用户查询列表接口 get",notes = "用户查询列表接口 get",httpMethod = "GET", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public Map<String, Object> selectStaff(StaffVo staffVo) {
        return staffService.selectStaff(staffVo);
    }

    /**
     *
     * @param staffVo 前端对象
     * @return
     */
    @PostMapping("/insertStaff")
    public Map<String,Object> addStaff(@RequestBody StaffVo staffVo) {

        return staffService.insert(staffVo);
    }

    /**
     * 编辑数据
     *
     * @param updateStaffVo 实体
     * @return 编辑结果
     */
    @PostMapping("/updateById")
    public Map<String,Object> updateById(@RequestBody UpdateStaffVo updateStaffVo) {

        return staffService.updateById(updateStaffVo);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @PostMapping("/deleteStaff")
    public Map<String,Object> deleteById(@RequestParam Integer id) {
        return staffService.deleteById(id);
    }
    @PostMapping("/testPost")
    @ApiOperation(value = "用户查询列表接口 post",notes = "用户查询列表接口 post",httpMethod = "POST", response = String.class)
    public Map<String, Object> testPost() {
        return staffService.selectStaff(null);
    }


}

